package com.wecan.web.config;

import com.wecan.web.security.XssHttpServletFilter;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.annotation.PostConstruct;

/**
 * @Author liuzhihao
 * @Date 2022.01.15
 * @Version 1.0.0
 * @Description mvc拦截器
 */
@Configuration(proxyBeanMethods = false)
@Slf4j
public class WebMvcConfig {

    @PostConstruct
    public void postConstruct() {
        log.info("[APP] |- 初始化webmvc拦截器");
    }

    @Bean
    @ConditionalOnMissingBean(XssHttpServletFilter.class)
    public XssHttpServletFilter xssHttpServletFilter() {
        XssHttpServletFilter xssHttpServletFilter = new XssHttpServletFilter();
        log.trace("[APP] |- xss拦截器初始化完毕.");
        return xssHttpServletFilter;
    }
}
